package com.x.crm.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.crm.dao.PhoneRecordDao;
import com.x.crm.model.PhoneRecord;
import com.x.crm.rpc.PhoneRecordRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by Administrator on 2018/3/2.
 */

@Component
@Service(interfaceName = "com.x.crm.rpc.PhoneRecordRpcService", timeout = 60000)
public class PhoneRecordService extends BaseService implements PhoneRecordRpcService {
	@Autowired
	private PhoneRecordDao phoneRecordDao;

	public List<PhoneRecord> selectPhoneRecordList(PhoneRecord phoneRecord) {
		try {
			return phoneRecordDao.selectPhoneRecordList(phoneRecord);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0011, e);
		}
	}

	public PhoneRecord insertPhoneRecord(PhoneRecord phoneRecord) {
		try {
			phoneRecord.setCreatedTime(this.getDate(0));
			phoneRecord.setUpdatedTime(this.getDate(0));
			return this.insert(phoneRecord);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0011, e);
		}
	}

	public int updatePhoneRecord(PhoneRecord phoneRecord) {
		try {
			phoneRecord.setUpdatedTime(this.getDate(0));
			return this.update(phoneRecord);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0011, e);
		}
	}

	public int selectPhoneRecordNum(PhoneRecord phoneRecord) {
		try {
			return phoneRecordDao.selectPhoneRecordNum(phoneRecord);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0011, e);
		}
	}

	public PhoneRecord selectPhoneRecordById(PhoneRecord phoneRecord) {
		try {
			return phoneRecordDao.selectPhoneRecordById(phoneRecord);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0011, e);
		}
	}

}
